Data

# load data
dag <- read_csv(here("Data",  "dag.csv")) %>% filter(cite_weight > 0)

node_attributes <- read_csv(here("data", "node_attributes.csv"))

With visnetowrk

# all edges
edges <- lit$edgelist %>% 
  mutate(
    detail = paste(edge, mechanism, cites, sep = "<br>") %>% str_remove_all("NA"),
    type = edge,
    title = paste0("<p>", detail, "</p>"),
    #label = type,
    color = ifelse(str_detect(type, "^increase"), "#81a275", "#617d9f"),
    color = ifelse(str_detect(type, "^decrease"), "#b14552", color),
    value = cite_weight) %>%
  distinct()

core <- edges %>% filter(core, !is.na(cites))

cited <- edges %>% filter(cite_weight>0)



# node attributes
nodes <- lit$nodelist %>% mutate(label = node, 
                                 id = node,
                                 # scale nodes by degree
                                 icon.size = degree + 40,
                                 title = paste0("<p>", type, ": ", label,"</p>") %>% str_remove("NA:"),
                                 # levels in case we want Hierarchical Layout
                                 level = ifelse(type == "goal", 1:2, 3:4),
                                 # FontAwesome.com shapes for fun
                                 shape = "icon",
                                 icon.color = case_when(node %in% c(cited$to, cited$from) ~ "black",
                                                        !node %in% c(cited$to, cited$from) ~ "grey"),
                                 icon.code = case_when(type == "condition" ~ "f205", # chess board
                                                       type == "goal" ~ "f24e", # scale  "f05b", # crosshairs
                                                       type == "policy" ~ "f0e3", # gavel
                                                       type == "value" ~ "f004", # "f4be", # hand with heart
                                                       type == "effect" ~ "f080", # "f681", # data 
                                                       type == "metric" ~ "f1de",# "f548", # ruler 
                                                       TRUE ~ "f0c8"), #square
                                 icon.face =  "'FontAwesome'",
                                 icon.weight = "bold")

# OLD CODE - REPLACE 

# define function to plot
dag_plot <- function(dag){
node <- c(dag$from,
           dag$to)

nodes <- tibble(id = node %>% str_remove(".* - "),
                type = node %>% str_remove(" - .*")) %>% 
  filter(!is.na(id)) %>%
  distinct() %>%
    # removed nodes with multiple types
  add_count(id) %>% 
  filter(n == 1)

edges <- dag %>% transmute(
  from = from %>% str_remove(".* - "),
  to = to %>% str_remove(".* - "),
  detail = paste(edge, mechanism, cites, sep = "<br>") %>% str_remove_all("NA"), 
  type = edge
) %>% 
  filter(!is.na(from),!is.na(to)) %>% 
  distinct()



# calculate betweeness in order to scale nodes
graph <- igraph::graph.data.frame(edges, directed = T)
degree_value <- degree(graph, mode = "in")
nodes$icon.size <- degree_value[match(nodes$id, names(degree_value))] + 40

# add attributes
nodes <- nodes %>% mutate(label = id, 
                          title = paste0("<p>", type, ": ", label,"</p>"),
                          # levels in case we want Hierarchical Layout
                          level = ifelse(type == "goal", 1:2, 3:4),
                          # FontAwesome.com shapes for fun
                          shape = "icon",
                            icon.color = case_when(type =="goal" ~ "black",
                                                   type !="goal" ~ "black"),
                            icon.code = case_when(type == "condition" ~ "f205", # chess board
                                                  type == "goal" ~ "f24e", # scale  "f05b", # crosshairs
                                                  type == "policy" ~ "f0e3", # gavel
                                                  type == "value" ~ "f004", # "f4be", # hand with heart
                                                  type == "effect" ~ "f080", # "f681", # data 
                                                  type == "metric" ~ "f1de",# "f548", # ruler 
                                                  TRUE ~ "f0c8"), #square
                            icon.face =  "'FontAwesome'",
                            icon.weight = "bold")

# format edges
edges <- edges %>% mutate(
  title = paste0("<p>", detail, "</p>"),
  #label = type,
  color = ifelse(str_detect(type, "^increase"), "#81a275", "#617d9f"),
  color = ifelse(str_detect(type, "^decrease"), "#b14552", color) ) 



# make directed graph
visNetwork(nodes=nodes, edges=edges, width = "100%") %>% 
  visEdges(width=5, color= edges$color, arrows = "to", arrowStrikethrough = F, smooth = T) %>%
  visNodes(scaling=list(min=40, max=50)) %>%
  visOptions(highlightNearest = list(enabled = T, degree = 1, hover = T)) %>%
  visInteraction(hover=TRUE, zoomView = TRUE) %>%
  #visHierarchicalLayout() %>% 
  visPhysics(solver = "forceAtlas2Based", forceAtlas2Based = list(gravitationalConstant = -50)) %>%
  addFontAwesome(name = "font-awesome-visNetwork") %>%
visLayout(randomSeed = 12) # to have always the same network  

# save datasets to call in Shiny
#save(nodes, file = here::here("dag", "nodes.RData"))
#save(edges, file = here::here("dag", "edges.RData"))

}

The core nodes

# plot core nodes
dag_plot(dag %>% filter(core) )

The whole mess

# plot core nodes
dag_plot(dag)

Using the NetLit R Package

How do we convert these data into a network object in R? There are multiple packages to work with networks, but the most popular is igraph because it’s very flexible and easy to do. Other packages that you may want to explore are sna and networks.

Now, how do we create the igraph object? We can use the graph_from_data_frame function, which takes two arguments: d, the data frame with the edge list in the first two columns; and vertices, a data frame with node data with the node label in the first column. (Note that igraph calls the nodes vertices, but it’s exactly the same thing.)

The review package from the netLit package provides a wrapper for formatting data for igraph. It returns a list of three objects, an edgelist, a nodelist with basic network statistics (eg betweenness) calculated, and a graph object that is the input to more advanced igraph functions.

Install this package with

devtools::install_github("judgelord/NetLit")

This package provides functions to generate network statistics from a literature review. Specifically, it takes data where each row is a proposed relationship (“edges”) between two concepts or variables (“nodes”).

Basic Usage

The review() function takes in a dataframe, data, that must include from and to columns (a directed graph structure).

The package loads example data from this project on redistricting.

data <- dag %>% select(from, to, #edge, 
               #mechanism, 
               cites) %>% mutate(cites = cites %>% str_remove(",.*|;.*"))

data
## # A tibble: 58 × 3
##    from                                  to                      cites          
##    <chr>                                 <chr>                   <chr>          
##  1 computers                             detect gerrymandering   Altman & McDon…
##  2 computers                             public participation    Altman & McDon…
##  3 legislator information about district floor votes align with… Butler         
##  4 number of competitive districts       preserve communities o… Gimpel & Harbr…
##  5 partisan advantage                    proportionality         Caughey et al.…
##  6 partisan advantage                    number of competitive … <NA>           
##  7 partisan gerrymandering               efficiency gap          Chen 2017      
##  8 preserve communities of interest      constitutional test     Stephanopoulos…
##  9 mean-median vote comparison           detect gerrymandering   McDonald & Bes…
## 10 mean-median vote comparison           constitutional test     McDonald & Bes…
## # … with 48 more rows

review() returns a list of 3:

  1. an edgelist
  2. a nodelist augmented with a betweenness score from igraph::degree(),
  3. graph, an ’igraph` object
# devtools::install_github("judgelord/NetLit")
library(NetLit)

review(data = dag)
## $nodelist
## # A tibble: 51 × 3
##    node                                        degree betweenness
##    <chr>                                        <dbl>       <dbl>
##  1 detect gerrymandering                            2         0  
##  2 public participation                             1         0  
##  3 floor votes align with district preferences      2         0  
##  4 preserve communities of interest                 1        96  
##  5 proportionality                                  1        18  
##  6 number of competitive districts                  4        85.5
##  7 efficiency gap                                   3         0  
##  8 constitutional test                              2         0  
##  9 unconstitutional government interest             1         0  
## 10 instability                                      1         0  
## # … with 41 more rows
## 
## $edgelist
## # A tibble: 58 × 3
##    from                                  to                     edge_betweenness
##    <chr>                                 <chr>                             <dbl>
##  1 computers                             detect gerrymandering                 1
##  2 computers                             public participation                  1
##  3 legislator information about district floor votes align wit…                1
##  4 number of competitive districts       preserve communities …              104
##  5 partisan advantage                    proportionality                      27
##  6 partisan advantage                    number of competitive…               29
##  7 partisan gerrymandering               efficiency gap                        5
##  8 preserve communities of interest      constitutional test                   9
##  9 mean-median vote comparison           detect gerrymandering                 1
## 10 mean-median vote comparison           constitutional test                   1
## # … with 48 more rows
## 
## $graph
## IGRAPH 00800d5 DN-- 51 58 -- 
## + attr: name (v/c), degree (v/n), betweenness (v/n), edge_betweenness
## | (e/n)
## + edges from 00800d5 (vertex names):
## [1] computers                            ->detect gerrymandering                      
## [2] computers                            ->public participation                       
## [3] legislator information about district->floor votes align with district preferences
## [4] number of competitive districts      ->preserve communities of interest           
## [5] partisan advantage                   ->proportionality                            
## [6] partisan advantage                   ->number of competitive districts            
## + ... omitted several edges

Additional Features

Optional additional columns in the data argument may specify edge attributes (for example, in the example data below, edge, mechanism, and cites and attributes of the proposed relationship between the variables specified in the to and from columns.

Node attributes may be specified in an optional node_attributes argument. node_attributes must be a dataframe with a column node with values matching the to or from columns of the data argument.

lit <- review(dag)
edges <- lit$edgelist
kablebox(edges)
from to edge_betweenness
computers detect gerrymandering 1.0
computers public participation 1.0
legislator information about district floor votes align with district preferences 1.0
number of competitive districts preserve communities of interest 104.0
partisan advantage proportionality 27.0
partisan advantage number of competitive districts 29.0
partisan gerrymandering efficiency gap 5.0
preserve communities of interest constitutional test 9.0
mean-median vote comparison detect gerrymandering 1.0
mean-median vote comparison constitutional test 1.0
partisan gerrymandering unconstitutional government interest 9.0
partisan gerrymandering instability 9.0
partisan gerrymandering elite polarization 3.0
majority minority districts number of minority representatives 1.0
majority minority districts number of competitive districts 13.5
majority minority districts partisan advantage 8.5
majority minority districts voter turnout 1.0
redistricting commission partisan gerrymandering 22.0
partisan gerrymandering partisan donor advantage 9.0
change in constituency boundaries legislator voting 1.0
change in constituency boundaries legislative outcomes 1.0
competitiveness voter turnout 3.0
sorting elite polarization 1.0
contiguity partisan advantage 22.0
electorate composition change incumbent vote share 1.0
electorate composition change personal vote 1.0
House-Senate Delegation alignment pork spending 11.0
incumbent’s constituents change number of competitive districts 22.0
stability in voters’ fellow constituents voter sense of place 10.0
voter information about their district rolloff 1.0
voter information about their district voter recall 10.0
voter information about their district split ticket voting 10.0
electorate composition change campaign resource allocation 1.0
geographic clustering partisan advantage 22.0
preserve communities of interest stability in voters’ fellow constituents 18.0
preserve communities of interest voter information about their district 27.0
preserve communities of interest rolloff 9.0
number of competitive districts elite polarization 2.5
partisan advantage floor votes align with district preferences 9.0
partisan advantage floor votes align with state preferences 9.0
partisan advantage partisan advantage 0.0
partisan advantage legislator voting 9.0
partisan advantage elite polarization 3.5
partisan advantage efficiency gap 4.0
partisan advantage number of competitive districts 29.0
proportionality House-Senate Delegation alignment 20.0
compactness minority representation 1.0
compactness compactness 0.0
efficiency gap efficiency gap 0.0
equal population equal population 0.0
redistricting commission representation of majority opinion 1.0
redistricting commission elite ideological moderation 1.0
redistricting commission competitiveness 2.0
redistricting by courts competitiveness 2.0
upcoming redistricting legislative majority-seeking behavior 1.0
partisan dislocation partisan dislocation 0.0
partisan gerrymandering partisan advantage 54.0
preserve communities of interest partisan gerrymandering 54.0
nodes <- lit$nodelist
kablebox(nodes)
node degree betweenness
detect gerrymandering 2 0.0
public participation 1 0.0
floor votes align with district preferences 2 0.0
preserve communities of interest 1 96.0
proportionality 1 18.0
number of competitive districts 4 85.5
efficiency gap 3 0.0
constitutional test 2 0.0
unconstitutional government interest 1 0.0
instability 1 0.0
elite polarization 4 0.0
number of minority representatives 1 0.0
partisan advantage 5 98.5
voter turnout 2 0.0
partisan gerrymandering 2 68.0
partisan donor advantage 1 0.0
legislator voting 2 0.0
legislative outcomes 1 0.0
incumbent vote share 1 0.0
personal vote 1 0.0
pork spending 1 0.0
voter sense of place 1 0.0
rolloff 2 0.0
voter recall 1 0.0
split ticket voting 1 0.0
campaign resource allocation 1 0.0
stability in voters’ fellow constituents 1 9.0
voter information about their district 1 18.0
floor votes align with state preferences 1 0.0
House-Senate Delegation alignment 1 10.0
minority representation 1 0.0
compactness 1 0.0
equal population 1 0.0
representation of majority opinion 1 0.0
elite ideological moderation 1 0.0
competitiveness 2 2.0
legislative majority-seeking behavior 1 0.0
partisan dislocation 1 0.0
computers 0 0.0
legislator information about district 0 0.0
mean-median vote comparison 0 0.0
majority minority districts 0 0.0
redistricting commission 0 0.0
change in constituency boundaries 0 0.0
sorting 0 0.0
contiguity 0 0.0
electorate composition change 0 0.0
incumbent’s constituents change 0 0.0
geographic clustering 0 0.0
redistricting by courts 0 0.0
upcoming redistricting 0 0.0
# now with node and edge attributes 
lit <- review(dag,
              edge_attributes = c("mechanism", "cites", "cites_empirical", "cite_weight", "cite_weight_empirical") 
              #,node_attributes = node_attributes
              )

edges <- lit$edgelist
kablebox(edges)
from to mechanism cites cites_empirical cite_weight edge_betweenness
computers detect gerrymandering Altman and McDonald (2010) argue that simulations cannot adequately detect gerrymanders. Wang proposes three tests to detect the effects and intents of gerrymanders. Altman and McDonald (2011) provide an open source program for redistricting analysis Altman & McDonald 2010; Wang 2016; Altman & McDonald 2011 Wang 2016 3 1.0
computers public participation Altman & McDonald argue that computers can be used to allow the public to participate in the map-drawing process by soliciting information and education about redistricting. Altman & McDonald 2010; Altman & McDonald 2011 NA 2 1.0
legislator information about district floor votes align with district preferences NA Butler, D and Nickerson, D 2011; Broockman and Skovron 2018; and Hertel-Fernandez et al. 2018 NA 3 1.0
number of competitive districts preserve communities of interest If racial groups or like municipal jurisdictions have partisan leanings, then creating more competitive districts often means splitting communities across districts. Gimpel & Harbridge-Yong 2020 Gimpel & Harbridge-Yong 2020 1 104.0
partisan advantage proportionality A partisan gerrymander aims to diverge from proportionality. Caughey et al. 2017 NA 1 27.0
partisan advantage number of competitive districts A partisan gerrymander aims to decrease the number of competitive district, but some research suggests that partisan gerrymanders have a neutral or positive effect on competition. NA NA 5 29.0
partisan gerrymandering efficiency gap Chen conducts simulations of neutrally drawn districts in Wisconsin and compares the efficiency gap of simulations to that of the actual redistricting plan, in order to show that the map was designed to give an advantage to one party. Chen 2017 Chen 2017 1 5.0
preserve communities of interest constitutional test Stephanopoulos argues that the Supreme Court ought to adopt a test of political gerrymandering based on the “territorial community.” In short, if a district map disrupts an organic geographic community, it is unconstitutional. Stephanopoulos 2012 NA 1 9.0
mean-median vote comparison detect gerrymandering McDonald & Best propose a new measure of detecting gerrymanders; compare a party’s median vote share in a district to its mean vote share. Wang proposes a similar measure of gerrymandering based on comparing mean and median vote shares. McDonald & Best 2015, Wang 2016 Wang 2016 1 1.0
mean-median vote comparison constitutional test McDonald & Best argue that their measure of gerryamndering can be extended to identify which gerrymanders are unconstitutional McDonald & Best 2015 NA 1 1.0
partisan gerrymandering unconstitutional government interest Kang argues that it is unconstitutional for the government to take partisanship into account when determining district lines Kang 2017 NA 1 9.0
partisan gerrymandering instability Partisan mapmakers can create political instability, particularly for their opponent legislators, by breaking the link between representatives and constituents Yoshinaka & Murhpy 2011 Yoshinaka & Murhpy 2011 1 9.0
partisan gerrymandering elite polarization Masket et al. find that partisan redistricting do not have much effect on legislative polarization, as it is swamped by other factors Masket et al. 2012 Masket et al. 2012 1 3.0
majority minority districts number of minority representatives Where minorities are a majority, they are have a better chance of electing a representative; Atsusaka 2021 creates a logical model that allows minority candidate appearance to be a result of (1) the electoral performance of coethnic candidates in the most recent elections and (2) the racial composition of a district. Atsusaka 2021 Atsusaka 2021 1 1.0
majority minority districts number of competitive districts NA NA NA 2 13.5
majority minority districts partisan advantage Cox and Holden argue that the optimal gerrymandering strategy is to cluster your strong partisan supporters into districts with a smaller number of strong partisan opponents. Thus, the Voting Rights Act’s majority-minority districts limit Republicans’ ability to effectively gerrymander. Cox & Holden 2011 NA 1 8.5
majority minority districts voter turnout African Americans are more likely to vote when reassigned to a majority black district. Fraga relies on a theoretical “empowerment framework,” in which members of minority groups are more likely to participate when their group has representation and influence in politics. Fraga 2016 Fraga 2016 1 1.0
redistricting commission partisan gerrymandering Cain argues that independent citizen redistricting commissions are less likely to produce extremely partisan maps because they need to satisfy a supermajority by compromising on various redistricting criteria. Cain 2011 NA 1 22.0
partisan gerrymandering partisan donor advantage Parties care about other resources in addition to votes, such as donations. They can use redistricting to concentrate likely donors into their districts and remove them from opponents’ districts, thus increasing their odds of reelection. Kirkland 2013 Kirkland 2013 1 9.0
change in constituency boundaries legislator voting Bertelli and Carson argue that partisan gerrymandering is a form of risk-sharing, in which individual members do not have to radically change their positions while maintaining their odds of reelection. In contrast, Hayes et al. say that legislators respond to the demographic changes of their constituency after redistricting. Bertelli & Carson 2011, Hayes et al. 2010 Bertelli & Carson 2011, Hayes et al. 2010 1 1.0
change in constituency boundaries legislative outcomes Bertelli & Carson: Partisan gerrymandering helps the majority party achieve its policy goals by increasing the odds of electoral success without requiring much sacrifice by individual members. Gul & Pesendorfer: use formal theory to show that policy outcomes are biased towards the redistricting party Bertelli & Carson 2011, Gul & Pesendorfer 2010 Bertelli & Carson 2011 1 1.0
competitiveness voter turnout Moskowitz & Schneer 2019: Residents of competitive districts systematically differ from those in non-competitive districts, leading cross-sectional studies to erroneously find a relationship between competitiveness and turnout. In addition, most voters aren’t aware of the competitiveness of their House race. Hunt 2018: examines data from Florida during 2012 election and finds that change in competitiveness after redistricting has a small effect on turnout Moskowitz & Schneer 2019; Hunt 2018 Moskowitz & Schneer 2019; Hunt 2018 2 3.0
sorting elite polarization Krasa & Polborn 2018: electoral competition model where gerrymandering (“intensification of the median ideological preferences in some districts”) can result in increased partisan polarization Krasa & Polborn 2018 Krasa & Polborn 2018 1 1.0
contiguity partisan advantage Democrats’ concentration in cities leads to a Republican bias, due to the geographic, majoritarian nature of U.S. elections. Chen & Rodden 2013 Chen & Rodden 2013 1 22.0
electorate composition change incumbent vote share Hood and McKee find that redistricting destroys the connection between a representative and their constituents; the new constituents have no such bond, so incumbency advantage is lower. Ansolabehere and Snyder find similar results when comparing the vote margins of districted and non-districted incumbents. Hood & McKee 2013; Ansolabehere & Snyder 2012 Hood & McKee 2013; Ansolabehere & Snyder 2012 2 1.0
electorate composition change personal vote When a legislator’s district changes, the personal connection with some of their constituents is lost. Thus, legislators are less able to convert supporters of the opposite party, as they have no connections with their new constituents. Carsey et al. 2017, Bertelli & Carson 2011 Carsey et al. 2017 1 1.0
House-Senate Delegation alignment pork spending NA Chen 2010 NA 1 11.0
incumbent’s constituents change number of competitive districts NA NA NA 1 22.0
stability in voters’ fellow constituents voter sense of place NA Hayes & McKee 2011 Hayes & McKee 2011 1 10.0
voter information about their district rolloff NA Winburn & Wagner 2010 NA 1 1.0
voter information about their district voter recall NA Winburn & Wagner 2010 NA 1 10.0
voter information about their district split ticket voting NA Winburn & Wagner 2010 NA 1 10.0
electorate composition change campaign resource allocation Candidates have their own campaign style, so their resource allocation decisions do not change even when the electoral circumstances change. Limbocker & You 2020 Limbocker & You 2020 1 1.0
geographic clustering partisan advantage Democrats are inefficiently geographically distributed; they run up the score in large cities which leads to a discrepency between total vote share and seat share. Chen & Rodden 2013 Chen & Rodden 2013 1 22.0
preserve communities of interest stability in voters’ fellow constituents NA Winburn & Wagner 2010 NA 1 18.0
preserve communities of interest voter information about their district NA Winburn & Wagner 2010 NA 1 27.0
preserve communities of interest rolloff NA Hayes & McKee 2011; Winburn & Wagner 2010 Hayes & McKee 2011 2 9.0
number of competitive districts elite polarization Safe partisan seats tend to increase partisan polarization. Grainger 2010 Grainger 2010 1 2.5
partisan advantage floor votes align with district preferences TODO Caughey et al. 2017 NA 1 9.0
partisan advantage floor votes align with state preferences TODO Caughey et al. 2017 NA 1 9.0
partisan advantage partisan advantage Measures of partisan symmetry/bias/advantage Arrington 2016; Campisi et al. 2019; Katz, King & Rosenblatt 2020 NA 3 0.0
partisan advantage legislator voting Legislators do not change their ideological positions after redistricting (though The Electoral Connection suggests they should) Lo 2013 Lo 2013 1 9.0
partisan advantage elite polarization Because vulnerable legislators do not moderate their positions, Lo assumes that safe legislators do not become more extreme Lo 2013 NA 1 3.5
partisan advantage efficiency gap Gerrymandering does not affect the electoral results in most states, and in the states where it does have an effect, the effect is small. Republicans are expected to net only one additional seat in Congress due to gerrymandering. Chen & Cottrell 2016 Chen & Cottrell 2016 1 4.0
partisan advantage number of competitive districts Large changes in the national partisan tide causes garrymanders to backfire on the map-drawing party (an effect known as the “dummymander”), as their members face unexpectedly competitive elections. Goedert 2017 Goedert 2017, Yoshinaka & Murhpy 2011 1 29.0
proportionality House-Senate Delegation alignment NA Chen 2010 NA 1 20.0
compactness minority representation Webster 2013: citing earlier research, Webster posits that compactness hinders a map drawer’s ability to create districts for historically underrepresented groups. Webster 2013 NA 1 1.0
compactness compactness Barnes & Solomon 2020: measuring compactness can have associated flexibility that can be abused (geography, topography, cartographic projections, and resolution); Gatesman & Unwin 2021: lattice models for accounting gerrymandered, equal-pop, connected districts; Magleby & Mosesson 2018: graph partition algorithm for drawing districts based on compactness and equal population metrics.De Assis et al. 2014: Greedy randomized adaptive search procedure can balance multiple criteria, including compactness. Altman & McDonald 2011: produce an open source package that allows users to adjust weights of redistricting criteria, including redistricting. Liu et al.; propose a method of parallel evolutionary computation to solve the optimization problem of redistricting. Chen & Rodden; simulation-based method also takes compactness into account to draw district maps and identify gerrymanders. Tam Cho & Liu; use compactness in their redistricting algorithm. Saxon 2020: software for applying compactness/contiguity/equipopulation objectives to evaluate maps – specific focus on different definitions of compactness. Barnes & Solomon 2020; Gatesman & Unwin 2021; Magleby & Mosesson 2018; De Assis et al. 2014; Altman & McDonald 2011; Lie et al. 2016, Chen & Rodden 2015, Tam Cho & Liu 2016, Saxon 2020 Barnes & Solomon 2020; Magleby & Mosesson 2018; De Assis et al. 2014; Chen & Rodden 2015, Tam Cho & Liu 2016, Saxon 2020 6 0.0
efficiency gap efficiency gap Stephanopoulos and McGhee propose a measure of partisan symmetry to be adopted by the courts, in order to limit partisan influence over redistricting; McGhee distinguishes efficiency from related concepts of symmetry and responsiveness Stephanopoulos & McGhee 2015, McGhee 2014 McGhee 2014 1 0.0
equal population equal population Gatesman & Unwin 2021: lattice models for accounting gerrymandered, equal-pop, connected districts; Magleby & Mosesson 2018: graph partition algorithm for drawing districts based on compactness and equal population metrics. Altman & McDonald 2011: produce an open source package that allows users to adjust weights of redistricting criteria, including equality of population Gatesman & Unwin 2021; Magleby & Mosesson 2018 Magleby & Mosesson 2018 2 0.0
redistricting commission representation of majority opinion Matsusaka does not discuss a mechanism for this relationship, but finds that other electoral rules, such as campaign finance regulations and ballot access rules, are also not associated with greater congruence between public opinion and legislative behavior. Matsusaka 2010 Matsusaka 2010 1 1.0
redistricting commission elite ideological moderation McGhee and Shor focus on the effect of the Top Two primary on elite moderation, but argue that the introduction of independent redistricting commissions may also lead to greater moderation by creating more competitive districts. McGhee & Shor 2017 McGhee & Shor 2017 1 1.0
redistricting commission competitiveness Carson et al.: increased ideological polarization and the availability of redistricting computer software encourages elites to draw non-competitive districts in order to increase their odds of reelection. Masket et al.: partisan redistricting does not effect competition much and is swamped by other factors Carson et al. 2014, Grainger 2010, Masket et al. 2012 Carson et al. 2014, Grainger 2010, Masket et al. 2012 1 2.0
redistricting by courts competitiveness NA Carson et al. 2014 Carson et al. 2014 1 2.0
upcoming redistricting legislative majority-seeking behavior Parties have a greater incentive to become the majority party in the state legislature if redistricting is imminent and controlled by the legislature, as they can then determine the new district boundaries Makse 2014 Makse 2014 1 1.0
partisan dislocation partisan dislocation Deford, Eubank & Rodden 2020: new measure “partisan dislocation” which proxies for cracking/packing Deford, Eubank & Rodden 2020 NA 1 0.0
partisan gerrymandering partisan advantage The party in charge of the redistricting process draws maps to secure an electoral advantage. Wang 2016; Cox & Holden 2011 Cox & Holden 2011 2 54.0
preserve communities of interest partisan gerrymandering Some traditional districting principles, like preserving communities of interest, can constrain Sabouni & Shelton 2021 Sabouni & Shelton 2021 1 54.0
nodes <- lit$nodelist
kablebox(nodes)
node degree betweenness
detect gerrymandering 2 0.0
public participation 1 0.0
floor votes align with district preferences 2 0.0
preserve communities of interest 1 96.0
proportionality 1 18.0
number of competitive districts 4 85.5
efficiency gap 3 0.0
constitutional test 2 0.0
unconstitutional government interest 1 0.0
instability 1 0.0
elite polarization 4 0.0
number of minority representatives 1 0.0
partisan advantage 5 98.5
voter turnout 2 0.0
partisan gerrymandering 2 68.0
partisan donor advantage 1 0.0
legislator voting 2 0.0
legislative outcomes 1 0.0
incumbent vote share 1 0.0
personal vote 1 0.0
pork spending 1 0.0
voter sense of place 1 0.0
rolloff 2 0.0
voter recall 1 0.0
split ticket voting 1 0.0
campaign resource allocation 1 0.0
stability in voters’ fellow constituents 1 9.0
voter information about their district 1 18.0
floor votes align with state preferences 1 0.0
House-Senate Delegation alignment 1 10.0
minority representation 1 0.0
compactness 1 0.0
equal population 1 0.0
representation of majority opinion 1 0.0
elite ideological moderation 1 0.0
competitiveness 2 2.0
legislative majority-seeking behavior 1 0.0
partisan dislocation 1 0.0
computers 0 0.0
legislator information about district 0 0.0
mean-median vote comparison 0 0.0
majority minority districts 0 0.0
redistricting commission 0 0.0
change in constituency boundaries 0 0.0
sorting 0 0.0
contiguity 0 0.0
electorate composition change 0 0.0
incumbent’s constituents change 0 0.0
geographic clustering 0 0.0
redistricting by courts 0 0.0
upcoming redistricting 0 0.0

igraph object

# define node name
nodes$name <- nodes$node

g <- lit$graph
g
## IGRAPH ae145aa DN-- 51 58 -- 
## + attr: name (v/c), degree (v/n), betweenness (v/n), mechanism (e/c),
## | cites (e/c), cites_empirical (e/c), cite_weight (e/n),
## | edge_betweenness (e/n)
## + edges from ae145aa (vertex names):
## [1] computers                            ->detect gerrymandering                      
## [2] computers                            ->public participation                       
## [3] legislator information about district->floor votes align with district preferences
## [4] number of competitive districts      ->preserve communities of interest           
## [5] partisan advantage                   ->proportionality                            
## + ... omitted several edges

What does it mean?

  • D means directed
  • N means named graph
  • W means weighted graph
  • name (v/c) means name is a node attribute and it’s a character
  • cite_weight (e/n) means cite_weight is an edge attribute and it’s numeric

igraph statistics

2.1 Practice accessing elements of the network

Practice accessing the following elements of the network: nodes, names of the nodes, attributes of the nodes, edges, weights for each edge, all attributes of the edges, the adjacency matrix, and just the first row of the adjacency matrix.

#V(g)  # nodes
# V(g)$name %>% head() # names of each node
vertex_attr(g) %>% as_tibble() %>% kablebox()# all attributes of the nodes
name degree betweenness
detect gerrymandering 2 0.0
public participation 1 0.0
floor votes align with district preferences 2 0.0
preserve communities of interest 1 96.0
proportionality 1 18.0
number of competitive districts 4 85.5
efficiency gap 3 0.0
constitutional test 2 0.0
unconstitutional government interest 1 0.0
instability 1 0.0
elite polarization 4 0.0
number of minority representatives 1 0.0
partisan advantage 5 98.5
voter turnout 2 0.0
partisan gerrymandering 2 68.0
partisan donor advantage 1 0.0
legislator voting 2 0.0
legislative outcomes 1 0.0
incumbent vote share 1 0.0
personal vote 1 0.0
pork spending 1 0.0
voter sense of place 1 0.0
rolloff 2 0.0
voter recall 1 0.0
split ticket voting 1 0.0
campaign resource allocation 1 0.0
stability in voters’ fellow constituents 1 9.0
voter information about their district 1 18.0
floor votes align with state preferences 1 0.0
House-Senate Delegation alignment 1 10.0
minority representation 1 0.0
compactness 1 0.0
equal population 1 0.0
representation of majority opinion 1 0.0
elite ideological moderation 1 0.0
competitiveness 2 2.0
legislative majority-seeking behavior 1 0.0
partisan dislocation 1 0.0
computers 0 0.0
legislator information about district 0 0.0
mean-median vote comparison 0 0.0
majority minority districts 0 0.0
redistricting commission 0 0.0
change in constituency boundaries 0 0.0
sorting 0 0.0
contiguity 0 0.0
electorate composition change 0 0.0
incumbent’s constituents change 0 0.0
geographic clustering 0 0.0
redistricting by courts 0 0.0
upcoming redistricting 0 0.0
E(g)  %>% head()# edges
## + 6/58 edges from ae145aa (vertex names):
## [1] computers                            ->detect gerrymandering                      
## [2] computers                            ->public participation                       
## [3] legislator information about district->floor votes align with district preferences
## [4] number of competitive districts      ->preserve communities of interest           
## [5] partisan advantage                   ->proportionality                            
## [6] partisan advantage                   ->number of competitive districts
E(g)$cite_weight  %>% head()# weights for each edge
## [1] 3 2 3 1 1 5
edge_attr(g)  %>% as_tibble() %>%  kablebox()# all attributes of the edges
mechanism cites cites_empirical cite_weight edge_betweenness
Altman and McDonald (2010) argue that simulations cannot adequately detect gerrymanders. Wang proposes three tests to detect the effects and intents of gerrymanders. Altman and McDonald (2011) provide an open source program for redistricting analysis Altman & McDonald 2010; Wang 2016; Altman & McDonald 2011 Wang 2016 3 1.0
Altman & McDonald argue that computers can be used to allow the public to participate in the map-drawing process by soliciting information and education about redistricting. Altman & McDonald 2010; Altman & McDonald 2011 NA 2 1.0
NA Butler, D and Nickerson, D 2011; Broockman and Skovron 2018; and Hertel-Fernandez et al. 2018 NA 3 1.0
If racial groups or like municipal jurisdictions have partisan leanings, then creating more competitive districts often means splitting communities across districts. Gimpel & Harbridge-Yong 2020 Gimpel & Harbridge-Yong 2020 1 104.0
A partisan gerrymander aims to diverge from proportionality. Caughey et al. 2017 NA 1 27.0
A partisan gerrymander aims to decrease the number of competitive district, but some research suggests that partisan gerrymanders have a neutral or positive effect on competition. NA NA 5 29.0
Chen conducts simulations of neutrally drawn districts in Wisconsin and compares the efficiency gap of simulations to that of the actual redistricting plan, in order to show that the map was designed to give an advantage to one party. Chen 2017 Chen 2017 1 5.0
Stephanopoulos argues that the Supreme Court ought to adopt a test of political gerrymandering based on the “territorial community.” In short, if a district map disrupts an organic geographic community, it is unconstitutional. Stephanopoulos 2012 NA 1 9.0
McDonald & Best propose a new measure of detecting gerrymanders; compare a party’s median vote share in a district to its mean vote share. Wang proposes a similar measure of gerrymandering based on comparing mean and median vote shares. McDonald & Best 2015, Wang 2016 Wang 2016 1 1.0
McDonald & Best argue that their measure of gerryamndering can be extended to identify which gerrymanders are unconstitutional McDonald & Best 2015 NA 1 1.0
Kang argues that it is unconstitutional for the government to take partisanship into account when determining district lines Kang 2017 NA 1 9.0
Partisan mapmakers can create political instability, particularly for their opponent legislators, by breaking the link between representatives and constituents Yoshinaka & Murhpy 2011 Yoshinaka & Murhpy 2011 1 9.0
Masket et al. find that partisan redistricting do not have much effect on legislative polarization, as it is swamped by other factors Masket et al. 2012 Masket et al. 2012 1 3.0
Where minorities are a majority, they are have a better chance of electing a representative; Atsusaka 2021 creates a logical model that allows minority candidate appearance to be a result of (1) the electoral performance of coethnic candidates in the most recent elections and (2) the racial composition of a district. Atsusaka 2021 Atsusaka 2021 1 1.0
NA NA NA 2 13.5
Cox and Holden argue that the optimal gerrymandering strategy is to cluster your strong partisan supporters into districts with a smaller number of strong partisan opponents. Thus, the Voting Rights Act’s majority-minority districts limit Republicans’ ability to effectively gerrymander. Cox & Holden 2011 NA 1 8.5
African Americans are more likely to vote when reassigned to a majority black district. Fraga relies on a theoretical “empowerment framework,” in which members of minority groups are more likely to participate when their group has representation and influence in politics. Fraga 2016 Fraga 2016 1 1.0
Cain argues that independent citizen redistricting commissions are less likely to produce extremely partisan maps because they need to satisfy a supermajority by compromising on various redistricting criteria. Cain 2011 NA 1 22.0
Parties care about other resources in addition to votes, such as donations. They can use redistricting to concentrate likely donors into their districts and remove them from opponents’ districts, thus increasing their odds of reelection. Kirkland 2013 Kirkland 2013 1 9.0
Bertelli and Carson argue that partisan gerrymandering is a form of risk-sharing, in which individual members do not have to radically change their positions while maintaining their odds of reelection. In contrast, Hayes et al. say that legislators respond to the demographic changes of their constituency after redistricting. Bertelli & Carson 2011, Hayes et al. 2010 Bertelli & Carson 2011, Hayes et al. 2010 1 1.0
Bertelli & Carson: Partisan gerrymandering helps the majority party achieve its policy goals by increasing the odds of electoral success without requiring much sacrifice by individual members. Gul & Pesendorfer: use formal theory to show that policy outcomes are biased towards the redistricting party Bertelli & Carson 2011, Gul & Pesendorfer 2010 Bertelli & Carson 2011 1 1.0
Moskowitz & Schneer 2019: Residents of competitive districts systematically differ from those in non-competitive districts, leading cross-sectional studies to erroneously find a relationship between competitiveness and turnout. In addition, most voters aren’t aware of the competitiveness of their House race. Hunt 2018: examines data from Florida during 2012 election and finds that change in competitiveness after redistricting has a small effect on turnout Moskowitz & Schneer 2019; Hunt 2018 Moskowitz & Schneer 2019; Hunt 2018 2 3.0
Krasa & Polborn 2018: electoral competition model where gerrymandering (“intensification of the median ideological preferences in some districts”) can result in increased partisan polarization Krasa & Polborn 2018 Krasa & Polborn 2018 1 1.0
Democrats’ concentration in cities leads to a Republican bias, due to the geographic, majoritarian nature of U.S. elections. Chen & Rodden 2013 Chen & Rodden 2013 1 22.0
Hood and McKee find that redistricting destroys the connection between a representative and their constituents; the new constituents have no such bond, so incumbency advantage is lower. Ansolabehere and Snyder find similar results when comparing the vote margins of districted and non-districted incumbents. Hood & McKee 2013; Ansolabehere & Snyder 2012 Hood & McKee 2013; Ansolabehere & Snyder 2012 2 1.0
When a legislator’s district changes, the personal connection with some of their constituents is lost. Thus, legislators are less able to convert supporters of the opposite party, as they have no connections with their new constituents. Carsey et al. 2017, Bertelli & Carson 2011 Carsey et al. 2017 1 1.0
NA Chen 2010 NA 1 11.0
NA NA NA 1 22.0
NA Hayes & McKee 2011 Hayes & McKee 2011 1 10.0
NA Winburn & Wagner 2010 NA 1 1.0
NA Winburn & Wagner 2010 NA 1 10.0
NA Winburn & Wagner 2010 NA 1 10.0
Candidates have their own campaign style, so their resource allocation decisions do not change even when the electoral circumstances change. Limbocker & You 2020 Limbocker & You 2020 1 1.0
Democrats are inefficiently geographically distributed; they run up the score in large cities which leads to a discrepency between total vote share and seat share. Chen & Rodden 2013 Chen & Rodden 2013 1 22.0
NA Winburn & Wagner 2010 NA 1 18.0
NA Winburn & Wagner 2010 NA 1 27.0
NA Hayes & McKee 2011; Winburn & Wagner 2010 Hayes & McKee 2011 2 9.0
Safe partisan seats tend to increase partisan polarization. Grainger 2010 Grainger 2010 1 2.5
TODO Caughey et al. 2017 NA 1 9.0
TODO Caughey et al. 2017 NA 1 9.0
Measures of partisan symmetry/bias/advantage Arrington 2016; Campisi et al. 2019; Katz, King & Rosenblatt 2020 NA 3 0.0
Legislators do not change their ideological positions after redistricting (though The Electoral Connection suggests they should) Lo 2013 Lo 2013 1 9.0
Because vulnerable legislators do not moderate their positions, Lo assumes that safe legislators do not become more extreme Lo 2013 NA 1 3.5
Gerrymandering does not affect the electoral results in most states, and in the states where it does have an effect, the effect is small. Republicans are expected to net only one additional seat in Congress due to gerrymandering. Chen & Cottrell 2016 Chen & Cottrell 2016 1 4.0
Large changes in the national partisan tide causes garrymanders to backfire on the map-drawing party (an effect known as the “dummymander”), as their members face unexpectedly competitive elections. Goedert 2017 Goedert 2017, Yoshinaka & Murhpy 2011 1 29.0
NA Chen 2010 NA 1 20.0
Webster 2013: citing earlier research, Webster posits that compactness hinders a map drawer’s ability to create districts for historically underrepresented groups. Webster 2013 NA 1 1.0
Barnes & Solomon 2020: measuring compactness can have associated flexibility that can be abused (geography, topography, cartographic projections, and resolution); Gatesman & Unwin 2021: lattice models for accounting gerrymandered, equal-pop, connected districts; Magleby & Mosesson 2018: graph partition algorithm for drawing districts based on compactness and equal population metrics.De Assis et al. 2014: Greedy randomized adaptive search procedure can balance multiple criteria, including compactness. Altman & McDonald 2011: produce an open source package that allows users to adjust weights of redistricting criteria, including redistricting. Liu et al.; propose a method of parallel evolutionary computation to solve the optimization problem of redistricting. Chen & Rodden; simulation-based method also takes compactness into account to draw district maps and identify gerrymanders. Tam Cho & Liu; use compactness in their redistricting algorithm. Saxon 2020: software for applying compactness/contiguity/equipopulation objectives to evaluate maps – specific focus on different definitions of compactness. Barnes & Solomon 2020; Gatesman & Unwin 2021; Magleby & Mosesson 2018; De Assis et al. 2014; Altman & McDonald 2011; Lie et al. 2016, Chen & Rodden 2015, Tam Cho & Liu 2016, Saxon 2020 Barnes & Solomon 2020; Magleby & Mosesson 2018; De Assis et al. 2014; Chen & Rodden 2015, Tam Cho & Liu 2016, Saxon 2020 6 0.0
Stephanopoulos and McGhee propose a measure of partisan symmetry to be adopted by the courts, in order to limit partisan influence over redistricting; McGhee distinguishes efficiency from related concepts of symmetry and responsiveness Stephanopoulos & McGhee 2015, McGhee 2014 McGhee 2014 1 0.0
Gatesman & Unwin 2021: lattice models for accounting gerrymandered, equal-pop, connected districts; Magleby & Mosesson 2018: graph partition algorithm for drawing districts based on compactness and equal population metrics. Altman & McDonald 2011: produce an open source package that allows users to adjust weights of redistricting criteria, including equality of population Gatesman & Unwin 2021; Magleby & Mosesson 2018 Magleby & Mosesson 2018 2 0.0
Matsusaka does not discuss a mechanism for this relationship, but finds that other electoral rules, such as campaign finance regulations and ballot access rules, are also not associated with greater congruence between public opinion and legislative behavior. Matsusaka 2010 Matsusaka 2010 1 1.0
McGhee and Shor focus on the effect of the Top Two primary on elite moderation, but argue that the introduction of independent redistricting commissions may also lead to greater moderation by creating more competitive districts. McGhee & Shor 2017 McGhee & Shor 2017 1 1.0
Carson et al.: increased ideological polarization and the availability of redistricting computer software encourages elites to draw non-competitive districts in order to increase their odds of reelection. Masket et al.: partisan redistricting does not effect competition much and is swamped by other factors Carson et al. 2014, Grainger 2010, Masket et al. 2012 Carson et al. 2014, Grainger 2010, Masket et al. 2012 1 2.0
NA Carson et al. 2014 Carson et al. 2014 1 2.0
Parties have a greater incentive to become the majority party in the state legislature if redistricting is imminent and controlled by the legislature, as they can then determine the new district boundaries Makse 2014 Makse 2014 1 1.0
Deford, Eubank & Rodden 2020: new measure “partisan dislocation” which proxies for cracking/packing Deford, Eubank & Rodden 2020 NA 1 0.0
The party in charge of the redistricting process draws maps to secure an electoral advantage. Wang 2016; Cox & Holden 2011 Cox & Holden 2011 2 54.0
Some traditional districting principles, like preserving communities of interest, can constrain Sabouni & Shelton 2021 Sabouni & Shelton 2021 1 54.0
# g[] %>% head # adjacency matrix
g[1,] %>% head # first row of adjacency matrix
##                       detect gerrymandering 
##                                           0 
##                        public participation 
##                                           0 
## floor votes align with district preferences 
##                                           0 
##            preserve communities of interest 
##                                           0 
##                             proportionality 
##                                           0 
##             number of competitive districts 
##                                           0

2.2 Network visualization with igraph::plot()

How can we visualize this network? The plot() function works out of the box, but the default options are often not ideal:

par(mar=c(0,0,0,0))
plot(g)

Improve this figure. To see all the available plotting options, you can check ?igraph.plotting. Set the vertex color, label colors, the size of the labels, curvature to the edge and edge color to ones different from the default settings and in a way that is visually appealing to you.

par(mar=c(0,0,0,0))

pdf(file="net.pdf")
plot(g,
     vertex.color = "grey", # change color of nodes
     vertex.label.color = "black", # change color of labels
     vertex.label.cex = .25, # change size of labels to 25% of original size
     edge.curved=.25, # add a 25% curve to the edges
     arrow.size = .2,
     edge.color="grey20") # change edge color to grey
dev.off()
## quartz_off_screen 
##                 2

With ggnetwork

# install.packages("ggnetwork")
library(ggnetwork)
n <- ggnetwork(g)

library(magrittr)

n$name %<>% str_replace(" ", "\n")

n$name %<>% str_replace(" ([A-z]*)$", "\n\\1")


library(magrittr)
 n$cite_weight %<>%  replace_na(0) 
 
n %<>% mutate(partisan = str_detect(name, "partisan"),
              empirical = ifelse(!is.na(cites_empirical),
                                 "Empirical work", 
                                 "No empirical work"))

n2 <- n %>% filter(partisan) %>% mutate(partisan = FALSE)

n %<>% full_join(n2) %>% mutate(partisan = ifelse(partisan, "Mentions partisanship", "Other nodes"))

set.seed(12)

n$cite_weight %<>% as_factor()


p <- ggplot(n) +
  aes(x = x, y = y, xend = xend, yend = yend,
      label = name %>% str_to_title()) +
    geom_nodes(size = 10, alpha = .1) +
    geom_edges(aes(color = cite_weight, linetype = empirical ),
               curvature = 0.1, 
               alpha = .8,
               #box.padding = unit(1, "lines"),
             arrow = arrow(length = unit(6, "pt"), type = "closed")) +
  
    geom_nodetext_repel(size = 2.3) +
  theme_blank() + 
  labs(color = "Number of\nPublications",
       linetype = "") + 
  scale_color_viridis_d(option = "plasma", begin = 0, end = .9, direction = -1) 

p

seedplot <- function(seed){
  set.seed(seed)
  p
}

seq <- seq(from = 1, to = 200, by= 50)

#map(seq, seedplot)



p <-  p + geom_edgetext(aes(label = cites_empirical %>% str_remove(",.*"), 
                    color = cite_weight),
                size = 2,
                alpha = .2) 

p

p + facet_wrap("partisan")

Now modify some of these plotting attributes so that they are function of network properties. For example, a common adjustment is to change the size of the nodes and node labels so that they match their importance.

Here, strength will correspond to the number of scenes they appear in. Let the size of the node be determined by the strength, and only show the labels of character that appear in 10 or more scenes. Finally change the colors of the node based on what side they’re in (dark side or light side) and add an informative legend.

V(g)$size <- strength(g)
par(mar=c(0,0,0,0)); plot(g)

# taking the log to improve it
V(g)$size <- log(strength(g)) * 4 + 3
par(mar=c(0,0,0,0)); plot(g)

V(g)$label <- ifelse( strength(g)>=10, V(g)$name, NA )
par(mar=c(0,0,0,0)); plot(g)

# what does `ifelse` do?
nodes$name=="minority rights"
##  [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [13] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [25] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [37] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [49] FALSE FALSE FALSE
ifelse(nodes$name=="minority rights", "yes", "no")
##  [1] "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no"
## [16] "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no"
## [31] "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no"
## [46] "no" "no" "no" "no" "no" "no"
ifelse(grepl("rights", nodes$name), "yes", "no")
##  [1] "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no"
## [16] "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no"
## [31] "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no" "no"
## [46] "no" "no" "no" "no" "no" "no"
#change the colors of each node based on what side they're in (dark side or light side).
# create vectors with characters in each side
dark_side <- c("minority rights")
light_side <- c("")
# node we'll create a new color variable as a node property
V(g)$color <- NA
V(g)$color[V(g)$type == "goal"] <- "red"
V(g)$color[V(g)$type == "policy"] <- "gold"
V(g)$color[V(g)$type == "effect"] <- "blue"
V(g)$color[V(g)$type == "value"] <- "white"
V(g)$color[V(g)$type == "condition"] <- "green"
V(g)$color[V(g)$type == "metric"] <- "purple"

V(g)$color[is.na(V(g)$type)] <- "grey20"
vertex_attr(g) %>% as_tibble()%>% kablebox()
name degree betweenness size label color
detect gerrymandering 2 0.0 5.772589 NA NA
public participation 1 0.0 3.000000 NA NA
floor votes align with district preferences 2 0.0 5.772589 NA NA
preserve communities of interest 1 96.0 10.167038 NA NA
proportionality 1 18.0 5.772589 NA NA
number of competitive districts 4 85.5 10.167038 NA NA
efficiency gap 3 0.0 8.545177 NA NA
constitutional test 2 0.0 5.772589 NA NA
unconstitutional government interest 1 0.0 3.000000 NA NA
instability 1 0.0 3.000000 NA NA
elite polarization 4 0.0 8.545177 NA NA
number of minority representatives 1 0.0 3.000000 NA NA
partisan advantage 5 98.5 13.556229 partisan advantage NA
voter turnout 2 0.0 5.772589 NA NA
partisan gerrymandering 2 68.0 11.317766 NA NA
partisan donor advantage 1 0.0 3.000000 NA NA
legislator voting 2 0.0 5.772589 NA NA
legislative outcomes 1 0.0 3.000000 NA NA
incumbent vote share 1 0.0 3.000000 NA NA
personal vote 1 0.0 3.000000 NA NA
pork spending 1 0.0 3.000000 NA NA
voter sense of place 1 0.0 3.000000 NA NA
rolloff 2 0.0 5.772589 NA NA
voter recall 1 0.0 3.000000 NA NA
split ticket voting 1 0.0 3.000000 NA NA
campaign resource allocation 1 0.0 3.000000 NA NA
stability in voters’ fellow constituents 1 9.0 5.772589 NA NA
voter information about their district 1 18.0 8.545177 NA NA
floor votes align with state preferences 1 0.0 3.000000 NA NA
House-Senate Delegation alignment 1 10.0 5.772589 NA NA
minority representation 1 0.0 3.000000 NA NA
compactness 1 0.0 7.394449 NA NA
equal population 1 0.0 5.772589 NA NA
representation of majority opinion 1 0.0 3.000000 NA NA
elite ideological moderation 1 0.0 3.000000 NA NA
competitiveness 2 2.0 7.394449 NA NA
legislative majority-seeking behavior 1 0.0 3.000000 NA NA
partisan dislocation 1 0.0 5.772589 NA NA
computers 0 0.0 5.772589 NA NA
legislator information about district 0 0.0 3.000000 NA NA
mean-median vote comparison 0 0.0 5.772589 NA NA
majority minority districts 0 0.0 8.545177 NA NA
redistricting commission 0 0.0 8.545177 NA NA
change in constituency boundaries 0 0.0 5.772589 NA NA
sorting 0 0.0 3.000000 NA NA
contiguity 0 0.0 3.000000 NA NA
electorate composition change 0 0.0 7.394449 NA NA
incumbent’s constituents change 0 0.0 3.000000 NA NA
geographic clustering 0 0.0 3.000000 NA NA
redistricting by courts 0 0.0 3.000000 NA NA
upcoming redistricting 0 0.0 3.000000 NA NA
par(mar=c(0,0,0,0)); plot(g)

# what does %in% do?
1 %in% c(1,2,3,4)
## [1] TRUE
1 %in% c(2,3,4)
## [1] FALSE
#add a legend.
par(mar=c(0,0,0,0)); plot(g)
legend(x=.75, y=.75, legend=c("no type provided in node attributes sheet"), 
       pch=21, pt.bg=c("grey20"), pt.cex=2, bty="n")

Edge properties can also be modified. Set the width of each edge as a function of the log number of studies two concepts appear together. Plot it.

E(g)$width <- log(E(g)$cite_weight) + 1
edge_attr(g) %>% as_tibble() %>% kablebox()
mechanism cites cites_empirical cite_weight edge_betweenness width
Altman and McDonald (2010) argue that simulations cannot adequately detect gerrymanders. Wang proposes three tests to detect the effects and intents of gerrymanders. Altman and McDonald (2011) provide an open source program for redistricting analysis Altman & McDonald 2010; Wang 2016; Altman & McDonald 2011 Wang 2016 3 1.0 2.098612
Altman & McDonald argue that computers can be used to allow the public to participate in the map-drawing process by soliciting information and education about redistricting. Altman & McDonald 2010; Altman & McDonald 2011 NA 2 1.0 1.693147
NA Butler, D and Nickerson, D 2011; Broockman and Skovron 2018; and Hertel-Fernandez et al. 2018 NA 3 1.0 2.098612
If racial groups or like municipal jurisdictions have partisan leanings, then creating more competitive districts often means splitting communities across districts. Gimpel & Harbridge-Yong 2020 Gimpel & Harbridge-Yong 2020 1 104.0 1.000000
A partisan gerrymander aims to diverge from proportionality. Caughey et al. 2017 NA 1 27.0 1.000000
A partisan gerrymander aims to decrease the number of competitive district, but some research suggests that partisan gerrymanders have a neutral or positive effect on competition. NA NA 5 29.0 2.609438
Chen conducts simulations of neutrally drawn districts in Wisconsin and compares the efficiency gap of simulations to that of the actual redistricting plan, in order to show that the map was designed to give an advantage to one party. Chen 2017 Chen 2017 1 5.0 1.000000
Stephanopoulos argues that the Supreme Court ought to adopt a test of political gerrymandering based on the “territorial community.” In short, if a district map disrupts an organic geographic community, it is unconstitutional. Stephanopoulos 2012 NA 1 9.0 1.000000
McDonald & Best propose a new measure of detecting gerrymanders; compare a party’s median vote share in a district to its mean vote share. Wang proposes a similar measure of gerrymandering based on comparing mean and median vote shares. McDonald & Best 2015, Wang 2016 Wang 2016 1 1.0 1.000000
McDonald & Best argue that their measure of gerryamndering can be extended to identify which gerrymanders are unconstitutional McDonald & Best 2015 NA 1 1.0 1.000000
Kang argues that it is unconstitutional for the government to take partisanship into account when determining district lines Kang 2017 NA 1 9.0 1.000000
Partisan mapmakers can create political instability, particularly for their opponent legislators, by breaking the link between representatives and constituents Yoshinaka & Murhpy 2011 Yoshinaka & Murhpy 2011 1 9.0 1.000000
Masket et al. find that partisan redistricting do not have much effect on legislative polarization, as it is swamped by other factors Masket et al. 2012 Masket et al. 2012 1 3.0 1.000000
Where minorities are a majority, they are have a better chance of electing a representative; Atsusaka 2021 creates a logical model that allows minority candidate appearance to be a result of (1) the electoral performance of coethnic candidates in the most recent elections and (2) the racial composition of a district. Atsusaka 2021 Atsusaka 2021 1 1.0 1.000000
NA NA NA 2 13.5 1.693147
Cox and Holden argue that the optimal gerrymandering strategy is to cluster your strong partisan supporters into districts with a smaller number of strong partisan opponents. Thus, the Voting Rights Act’s majority-minority districts limit Republicans’ ability to effectively gerrymander. Cox & Holden 2011 NA 1 8.5 1.000000
African Americans are more likely to vote when reassigned to a majority black district. Fraga relies on a theoretical “empowerment framework,” in which members of minority groups are more likely to participate when their group has representation and influence in politics. Fraga 2016 Fraga 2016 1 1.0 1.000000
Cain argues that independent citizen redistricting commissions are less likely to produce extremely partisan maps because they need to satisfy a supermajority by compromising on various redistricting criteria. Cain 2011 NA 1 22.0 1.000000
Parties care about other resources in addition to votes, such as donations. They can use redistricting to concentrate likely donors into their districts and remove them from opponents’ districts, thus increasing their odds of reelection. Kirkland 2013 Kirkland 2013 1 9.0 1.000000
Bertelli and Carson argue that partisan gerrymandering is a form of risk-sharing, in which individual members do not have to radically change their positions while maintaining their odds of reelection. In contrast, Hayes et al. say that legislators respond to the demographic changes of their constituency after redistricting. Bertelli & Carson 2011, Hayes et al. 2010 Bertelli & Carson 2011, Hayes et al. 2010 1 1.0 1.000000
Bertelli & Carson: Partisan gerrymandering helps the majority party achieve its policy goals by increasing the odds of electoral success without requiring much sacrifice by individual members. Gul & Pesendorfer: use formal theory to show that policy outcomes are biased towards the redistricting party Bertelli & Carson 2011, Gul & Pesendorfer 2010 Bertelli & Carson 2011 1 1.0 1.000000
Moskowitz & Schneer 2019: Residents of competitive districts systematically differ from those in non-competitive districts, leading cross-sectional studies to erroneously find a relationship between competitiveness and turnout. In addition, most voters aren’t aware of the competitiveness of their House race. Hunt 2018: examines data from Florida during 2012 election and finds that change in competitiveness after redistricting has a small effect on turnout Moskowitz & Schneer 2019; Hunt 2018 Moskowitz & Schneer 2019; Hunt 2018 2 3.0 1.693147
Krasa & Polborn 2018: electoral competition model where gerrymandering (“intensification of the median ideological preferences in some districts”) can result in increased partisan polarization Krasa & Polborn 2018 Krasa & Polborn 2018 1 1.0 1.000000
Democrats’ concentration in cities leads to a Republican bias, due to the geographic, majoritarian nature of U.S. elections. Chen & Rodden 2013 Chen & Rodden 2013 1 22.0 1.000000
Hood and McKee find that redistricting destroys the connection between a representative and their constituents; the new constituents have no such bond, so incumbency advantage is lower. Ansolabehere and Snyder find similar results when comparing the vote margins of districted and non-districted incumbents. Hood & McKee 2013; Ansolabehere & Snyder 2012 Hood & McKee 2013; Ansolabehere & Snyder 2012 2 1.0 1.693147
When a legislator’s district changes, the personal connection with some of their constituents is lost. Thus, legislators are less able to convert supporters of the opposite party, as they have no connections with their new constituents. Carsey et al. 2017, Bertelli & Carson 2011 Carsey et al. 2017 1 1.0 1.000000
NA Chen 2010 NA 1 11.0 1.000000
NA NA NA 1 22.0 1.000000
NA Hayes & McKee 2011 Hayes & McKee 2011 1 10.0 1.000000
NA Winburn & Wagner 2010 NA 1 1.0 1.000000
NA Winburn & Wagner 2010 NA 1 10.0 1.000000
NA Winburn & Wagner 2010 NA 1 10.0 1.000000
Candidates have their own campaign style, so their resource allocation decisions do not change even when the electoral circumstances change. Limbocker & You 2020 Limbocker & You 2020 1 1.0 1.000000
Democrats are inefficiently geographically distributed; they run up the score in large cities which leads to a discrepency between total vote share and seat share. Chen & Rodden 2013 Chen & Rodden 2013 1 22.0 1.000000
NA Winburn & Wagner 2010 NA 1 18.0 1.000000
NA Winburn & Wagner 2010 NA 1 27.0 1.000000
NA Hayes & McKee 2011; Winburn & Wagner 2010 Hayes & McKee 2011 2 9.0 1.693147
Safe partisan seats tend to increase partisan polarization. Grainger 2010 Grainger 2010 1 2.5 1.000000
TODO Caughey et al. 2017 NA 1 9.0 1.000000
TODO Caughey et al. 2017 NA 1 9.0 1.000000
Measures of partisan symmetry/bias/advantage Arrington 2016; Campisi et al. 2019; Katz, King & Rosenblatt 2020 NA 3 0.0 2.098612
Legislators do not change their ideological positions after redistricting (though The Electoral Connection suggests they should) Lo 2013 Lo 2013 1 9.0 1.000000
Because vulnerable legislators do not moderate their positions, Lo assumes that safe legislators do not become more extreme Lo 2013 NA 1 3.5 1.000000
Gerrymandering does not affect the electoral results in most states, and in the states where it does have an effect, the effect is small. Republicans are expected to net only one additional seat in Congress due to gerrymandering. Chen & Cottrell 2016 Chen & Cottrell 2016 1 4.0 1.000000
Large changes in the national partisan tide causes garrymanders to backfire on the map-drawing party (an effect known as the “dummymander”), as their members face unexpectedly competitive elections. Goedert 2017 Goedert 2017, Yoshinaka & Murhpy 2011 1 29.0 1.000000
NA Chen 2010 NA 1 20.0 1.000000
Webster 2013: citing earlier research, Webster posits that compactness hinders a map drawer’s ability to create districts for historically underrepresented groups. Webster 2013 NA 1 1.0 1.000000
Barnes & Solomon 2020: measuring compactness can have associated flexibility that can be abused (geography, topography, cartographic projections, and resolution); Gatesman & Unwin 2021: lattice models for accounting gerrymandered, equal-pop, connected districts; Magleby & Mosesson 2018: graph partition algorithm for drawing districts based on compactness and equal population metrics.De Assis et al. 2014: Greedy randomized adaptive search procedure can balance multiple criteria, including compactness. Altman & McDonald 2011: produce an open source package that allows users to adjust weights of redistricting criteria, including redistricting. Liu et al.; propose a method of parallel evolutionary computation to solve the optimization problem of redistricting. Chen & Rodden; simulation-based method also takes compactness into account to draw district maps and identify gerrymanders. Tam Cho & Liu; use compactness in their redistricting algorithm. Saxon 2020: software for applying compactness/contiguity/equipopulation objectives to evaluate maps – specific focus on different definitions of compactness. Barnes & Solomon 2020; Gatesman & Unwin 2021; Magleby & Mosesson 2018; De Assis et al. 2014; Altman & McDonald 2011; Lie et al. 2016, Chen & Rodden 2015, Tam Cho & Liu 2016, Saxon 2020 Barnes & Solomon 2020; Magleby & Mosesson 2018; De Assis et al. 2014; Chen & Rodden 2015, Tam Cho & Liu 2016, Saxon 2020 6 0.0 2.791759
Stephanopoulos and McGhee propose a measure of partisan symmetry to be adopted by the courts, in order to limit partisan influence over redistricting; McGhee distinguishes efficiency from related concepts of symmetry and responsiveness Stephanopoulos & McGhee 2015, McGhee 2014 McGhee 2014 1 0.0 1.000000
Gatesman & Unwin 2021: lattice models for accounting gerrymandered, equal-pop, connected districts; Magleby & Mosesson 2018: graph partition algorithm for drawing districts based on compactness and equal population metrics. Altman & McDonald 2011: produce an open source package that allows users to adjust weights of redistricting criteria, including equality of population Gatesman & Unwin 2021; Magleby & Mosesson 2018 Magleby & Mosesson 2018 2 0.0 1.693147
Matsusaka does not discuss a mechanism for this relationship, but finds that other electoral rules, such as campaign finance regulations and ballot access rules, are also not associated with greater congruence between public opinion and legislative behavior. Matsusaka 2010 Matsusaka 2010 1 1.0 1.000000
McGhee and Shor focus on the effect of the Top Two primary on elite moderation, but argue that the introduction of independent redistricting commissions may also lead to greater moderation by creating more competitive districts. McGhee & Shor 2017 McGhee & Shor 2017 1 1.0 1.000000
Carson et al.: increased ideological polarization and the availability of redistricting computer software encourages elites to draw non-competitive districts in order to increase their odds of reelection. Masket et al.: partisan redistricting does not effect competition much and is swamped by other factors Carson et al. 2014, Grainger 2010, Masket et al. 2012 Carson et al. 2014, Grainger 2010, Masket et al. 2012 1 2.0 1.000000
NA Carson et al. 2014 Carson et al. 2014 1 2.0 1.000000
Parties have a greater incentive to become the majority party in the state legislature if redistricting is imminent and controlled by the legislature, as they can then determine the new district boundaries Makse 2014 Makse 2014 1 1.0 1.000000
Deford, Eubank & Rodden 2020: new measure “partisan dislocation” which proxies for cracking/packing Deford, Eubank & Rodden 2020 NA 1 0.0 1.000000
The party in charge of the redistricting process draws maps to secure an electoral advantage. Wang 2016; Cox & Holden 2011 Cox & Holden 2011 2 54.0 1.693147
Some traditional districting principles, like preserving communities of interest, can constrain Sabouni & Shelton 2021 Sabouni & Shelton 2021 1 54.0 1.000000
par(mar=c(0,0,0,0)); plot(g)

Extra: layouts

Up to now, each time we run the plot function, the nodes appear to be in a different location. Why? Because it’s running a probabilistic function trying to locate them in the optimal way possible.

However, we can also specify the layout for the plot; that is, the (x,y) coordinates where each node will be placed. igraph has a few different layouts built-in, that will use different algorithms to find an optimal distribution of nodes. The following code illustrates some of these:

par(mfrow=c(2, 3), mar=c(0,0,1,0))
plot(g, layout=layout_randomly, main="Random")
plot(g, layout=layout_in_circle, main="Circle")
plot(g, layout=layout_as_star, main="Star")
plot(g, layout=layout_as_tree, main="Tree")
plot(g, layout=layout_on_grid, main="Grid")
plot(g, layout=layout_with_fr, main="Force-directed")

Note that each of these is actually just a matrix of (x,y) locations for each node.

l <- layout_randomly(g)
str(l)
##  num [1:51, 1:2] 0.8335 0.8835 -0.7832 -0.2348 0.0684 ...

The most popular layouts are force-directed. These algorithms, such as Fruchterman-Reingold, try to position the nodes so that the edges have similar length and there are as few crossing edges as possible. The idea is to generate “clean” layouts, where nodes that are closer to each other share more connections in common that those that are located further apart. Note that this is a non-deterministic algorithm: choosing a different seed will generate different layouts.

par(mfrow=c(1,2))
set.seed(777)
fr <- layout_with_fr(g, niter=1000)
par(mar=c(0,0,0,0)); plot(g, layout=fr)
set.seed(666)
fr <- layout_with_fr(g, niter=1000)
par(mar=c(0,0,0,0)); plot(g, layout=fr)

3 Node properties

Let’s look at descriptive statistics at the node level. All of these are in some way measures of importance or centrality.

The most basic measure is degree, the number of adjacent edges to each node. It is often considered a measure of direct influence. In the redistricting network, it will be the unique number of concepts that each concept is interacting with. Sort the degree of the network and print it out.

sort(-degree(g)) %>% head() %>% kable()
x
partisan advantage -14
partisan gerrymandering -8
preserve communities of interest -6
number of competitive districts -6
efficiency gap -4
elite polarization -4

Partisan advantage (degree=14), followed by a three way tie of communities preserved, partisan gerrymandering and compactness (each degree=5) are the most “central” concepts covered in the redistricting literature.

In directed graphs, there are three types of degree: indegree (incoming edges), outdegree (outgoing edges), and total degree. You can find these using mode="in" or mode="out" or mode="total".

Strength is a weighted measure of degree that takes into account the number of edges that go from one node to another. In this network, it will be the total number of interactions of each concept with any other concept. Sort the strength of the network and print it out.

sort(-strength(g))  %>% head() %>% kable()
x
partisan advantage -14
partisan gerrymandering -8
preserve communities of interest -6
number of competitive districts -6
efficiency gap -4
elite polarization -4

Closeness measures how many steps are required to access every other node from a given node. It’s a measure of how long information takes to arrive (who hears news first?). Higher values mean less centrality. Sort the closeness of the network (normalize it) and print it out.

sort(-closeness(g, normalized=TRUE))
##                    redistricting commission 
##                                 -0.03822630 
##                 majority minority districts 
##                                 -0.03597122 
##                                  contiguity 
##                                 -0.03326680 
##                       geographic clustering 
##                                 -0.03326680 
##             incumbent's constituents change 
##                                 -0.03304693 
##            preserve communities of interest 
##                                 -0.03276540 
##                          partisan advantage 
##                                 -0.03263708 
##                     partisan gerrymandering 
##                                 -0.03255208 
##             number of competitive districts 
##                                 -0.03242542 
##      voter information about their district 
##                                 -0.02083333 
##               electorate composition change 
##                                 -0.02083333 
##                                   computers 
##                                 -0.02040816 
##                 mean-median vote comparison 
##                                 -0.02040816 
##           change in constituency boundaries 
##                                 -0.02040816 
##                             proportionality 
##                                 -0.02039984 
##                     redistricting by courts 
##                                 -0.02039984 
##    stability in voters' fellow constituents 
##                                 -0.02000000 
##           House-Senate Delegation alignment 
##                                 -0.02000000 
##                                 compactness 
##                                 -0.02000000 
##                             competitiveness 
##                                 -0.02000000 
##       legislator information about district 
##                                 -0.02000000 
##                                     sorting 
##                                 -0.02000000 
##                      upcoming redistricting 
##                                 -0.02000000 
##                       detect gerrymandering 
##                                 -0.01960784 
##                        public participation 
##                                 -0.01960784 
## floor votes align with district preferences 
##                                 -0.01960784 
##                              efficiency gap 
##                                 -0.01960784 
##                         constitutional test 
##                                 -0.01960784 
##        unconstitutional government interest 
##                                 -0.01960784 
##                                 instability 
##                                 -0.01960784 
##                          elite polarization 
##                                 -0.01960784 
##          number of minority representatives 
##                                 -0.01960784 
##                               voter turnout 
##                                 -0.01960784 
##                    partisan donor advantage 
##                                 -0.01960784 
##                           legislator voting 
##                                 -0.01960784 
##                        legislative outcomes 
##                                 -0.01960784 
##                        incumbent vote share 
##                                 -0.01960784 
##                               personal vote 
##                                 -0.01960784 
##                               pork spending 
##                                 -0.01960784 
##                        voter sense of place 
##                                 -0.01960784 
##                                     rolloff 
##                                 -0.01960784 
##                                voter recall 
##                                 -0.01960784 
##                         split ticket voting 
##                                 -0.01960784 
##                campaign resource allocation 
##                                 -0.01960784 
##    floor votes align with state preferences 
##                                 -0.01960784 
##                     minority representation 
##                                 -0.01960784 
##                            equal population 
##                                 -0.01960784 
##          representation of majority opinion 
##                                 -0.01960784 
##                elite ideological moderation 
##                                 -0.01960784 
##       legislative majority-seeking behavior 
##                                 -0.01960784 
##                        partisan dislocation 
##                                 -0.01960784

Detect gerrymandering, public participation, floor votes align with district preferences, and constitutional tests are closest to all other concepts in the network.

Betweenness measures brokerage or gatekeeping potential. It is (approximately) the number of shortest paths between nodes that pass through a particular node. Sort the betweenness of the network and print it out.

sort(-betweenness(g)) %>% head() %>% kable()
x
partisan advantage -98.5
preserve communities of interest -96.0
number of competitive districts -85.5
partisan gerrymandering -68.0
proportionality -18.0
voter information about their district -18.0

Partisan advantage has by far the highest measure of brokerage/gatekeeping potential, followed by number of competitive districts. These two concepts allow for the fastest facilitation of ideas in the redistricting network; in other words, if we were to design a causal story and try to connect two concepts, the fastest way to connect them would most often be through the idea of partisan advantage.

Eigenvector centrality is a measure of being well-connected connected to the well-connected. First eigenvector of the graph adjacency matrix. Only works with undirected networks. Sort the returned vector from the eigen_centrality of the network and print it out. (not for this application)

sort(-eigen_centrality(g)$vector) %>% head() %>% kable()

Page rank approximates probability that any message will arrive to a particular node. This algorithm was developed by Google founders, and originally applied to website links. Sort the returned vector from the page_rank of the network and print it out.

sort(page_rank(g)$vector)
##                                   computers 
##                                  0.01009203 
##       legislator information about district 
##                                  0.01009203 
##                 mean-median vote comparison 
##                                  0.01009203 
##                 majority minority districts 
##                                  0.01009203 
##                    redistricting commission 
##                                  0.01009203 
##           change in constituency boundaries 
##                                  0.01009203 
##                                     sorting 
##                                  0.01009203 
##                                  contiguity 
##                                  0.01009203 
##               electorate composition change 
##                                  0.01009203 
##             incumbent's constituents change 
##                                  0.01009203 
##                       geographic clustering 
##                                  0.01009203 
##                     redistricting by courts 
##                                  0.01009203 
##                      upcoming redistricting 
##                                  0.01009203 
##          number of minority representatives 
##                                  0.01223659 
##          representation of majority opinion 
##                                  0.01223659 
##                elite ideological moderation 
##                                  0.01223659 
##        unconstitutional government interest 
##                                  0.01234922 
##                                 instability 
##                                  0.01234922 
##                    partisan donor advantage 
##                                  0.01234922 
##                        incumbent vote share 
##                                  0.01295144 
##                               personal vote 
##                                  0.01295144 
##                campaign resource allocation 
##                                  0.01295144 
##    floor votes align with state preferences 
##                                  0.01339298 
##                             proportionality 
##                                  0.01339298 
##    stability in voters' fellow constituents 
##                                  0.01378853 
##      voter information about their district 
##                                  0.01378853 
##                                voter recall 
##                                  0.01399878 
##                         split ticket voting 
##                                  0.01399878 
##                        public participation 
##                                  0.01438115 
##                        legislative outcomes 
##                                  0.01438115 
##                     partisan gerrymandering 
##                                  0.01593309 
##                     minority representation 
##                                  0.01755136 
##                                 compactness 
##                                  0.01755136 
##                           legislator voting 
##                                  0.01768209 
##                                     rolloff 
##                                  0.01769529 
##                         constitutional test 
##                                  0.01807765 
##                       detect gerrymandering 
##                                  0.01867026 
##       legislative majority-seeking behavior 
##                                  0.01867026 
##                             competitiveness 
##                                  0.02081482 
##           House-Senate Delegation alignment 
##                                  0.02147606 
##            preserve communities of interest 
##                                  0.02174413 
##                        voter sense of place 
##                                  0.02181229 
## floor votes align with district preferences 
##                                  0.02197120 
##             number of competitive districts 
##                                  0.02741670 
##                               pork spending 
##                                  0.02834668 
##                               voter turnout 
##                                  0.02992918 
##                          partisan advantage 
##                                  0.03495118 
##                          elite polarization 
##                                  0.03588049 
##                            equal population 
##                                  0.06728021 
##                        partisan dislocation 
##                                  0.06728021 
##                              efficiency gap 
##                                  0.10433443

Authority score is another measure of centrality initially applied to the Web. A node has high authority when it is linked by many other nodes that are linking many other nodes. Sort the returned vector from the authority_score of the network and print it out.

sort(authority_score(g)$vector)
##                       detect gerrymandering 
##                                  0.00000000 
##                        public participation 
##                                  0.00000000 
##                         constitutional test 
##                                  0.00000000 
##                     partisan gerrymandering 
##                                  0.00000000 
##                        incumbent vote share 
##                                  0.00000000 
##                               personal vote 
##                                  0.00000000 
##                               pork spending 
##                                  0.00000000 
##                        voter sense of place 
##                                  0.00000000 
##                                     rolloff 
##                                  0.00000000 
##                                voter recall 
##                                  0.00000000 
##                         split ticket voting 
##                                  0.00000000 
##                campaign resource allocation 
##                                  0.00000000 
##    stability in voters' fellow constituents 
##                                  0.00000000 
##      voter information about their district 
##                                  0.00000000 
##           House-Senate Delegation alignment 
##                                  0.00000000 
##                     minority representation 
##                                  0.00000000 
##                                 compactness 
##                                  0.00000000 
##                            equal population 
##                                  0.00000000 
##          representation of majority opinion 
##                                  0.00000000 
##                elite ideological moderation 
##                                  0.00000000 
##                             competitiveness 
##                                  0.00000000 
##       legislative majority-seeking behavior 
##                                  0.00000000 
##                        partisan dislocation 
##                                  0.00000000 
##                                   computers 
##                                  0.00000000 
##       legislator information about district 
##                                  0.00000000 
##                 mean-median vote comparison 
##                                  0.00000000 
##                 majority minority districts 
##                                  0.00000000 
##                    redistricting commission 
##                                  0.00000000 
##           change in constituency boundaries 
##                                  0.00000000 
##                                     sorting 
##                                  0.00000000 
##                                  contiguity 
##                                  0.00000000 
##               electorate composition change 
##                                  0.00000000 
##             incumbent's constituents change 
##                                  0.00000000 
##                       geographic clustering 
##                                  0.00000000 
##                     redistricting by courts 
##                                  0.00000000 
##                      upcoming redistricting 
##                                  0.00000000 
##                        legislative outcomes 
##                                  0.03106878 
##            preserve communities of interest 
##                                  0.04909922 
##          number of minority representatives 
##                                  0.14597097 
##                               voter turnout 
##                                  0.15666850 
##        unconstitutional government interest 
##                                  0.18225367 
##                                 instability 
##                                  0.18225367 
##                    partisan donor advantage 
##                                  0.18225367 
##                             proportionality 
##                                  0.39287386 
##    floor votes align with state preferences 
##                                  0.39287386 
## floor votes align with district preferences 
##                                  0.42166575 
##                           legislator voting 
##                                  0.42394264 
##                              efficiency gap 
##                                  0.61727594 
##                          elite polarization 
##                                  0.66997341 
##                          partisan advantage 
##                                  0.83514857 
##             number of competitive districts 
##                                  1.00000000

Finally, not exactly a measure of centrality, but we can learn more about who each node is connected to by using the following functions: neighbors (for direct neighbors) and ego (for neighbors up to n neighbors away). Find the neighbors of “partisan advantage”. Find the concept’s neighbors up to order 2 away.

neighbors(g, v=which(V(g)$name=="partisan advantage"))
## + 9/51 vertices, named, from ae145aa:
## [1] floor votes align with district preferences
## [2] proportionality                            
## [3] number of competitive districts            
## [4] number of competitive districts            
## [5] efficiency gap                             
## [6] elite polarization                         
## [7] partisan advantage                         
## [8] legislator voting                          
## [9] floor votes align with state preferences
ego(g, order=2, nodes=which(V(g)$name=="partisan advantage"))
## [[1]]
## + 24/51 vertices, named, from ae145aa:
##  [1] partisan advantage                         
##  [2] floor votes align with district preferences
##  [3] proportionality                            
##  [4] number of competitive districts            
##  [5] efficiency gap                             
##  [6] elite polarization                         
##  [7] partisan gerrymandering                    
##  [8] legislator voting                          
##  [9] floor votes align with state preferences   
## [10] majority minority districts                
## + ... omitted several vertices

4 Network properties

Let’s now try to describe what a network looks like as a whole. We can start with measures of the size of a network. diameter is the length of the longest path (in number of edges) between two nodes. We can use get_diameter to identify this path. mean_distance is the average number of edges between any two nodes in the network. We can find each of these paths between pairs of edges with distances. Find the diameter and mean distances of the network.

diameter(g, directed=TRUE, weights=NA)
## [1] 7
get_diameter(g, directed=TRUE, weights=NA)
## + 8/51 vertices, named, from ae145aa:
## [1] incumbent's constituents change   number of competitive districts  
## [3] preserve communities of interest  partisan gerrymandering          
## [5] partisan advantage                proportionality                  
## [7] House-Senate Delegation alignment pork spending
mean_distance(g, directed=TRUE)
## [1] 2.816143
dist <- distances(g, weights=NA)
dist[1:5, 1:5]
##                                             detect gerrymandering
## detect gerrymandering                                           0
## public participation                                            2
## floor votes align with district preferences                     6
## preserve communities of interest                                3
## proportionality                                                 6
##                                             public participation
## detect gerrymandering                                          2
## public participation                                           0
## floor votes align with district preferences                    8
## preserve communities of interest                               5
## proportionality                                                8
##                                             floor votes align with district preferences
## detect gerrymandering                                                                 6
## public participation                                                                  8
## floor votes align with district preferences                                           0
## preserve communities of interest                                                      3
## proportionality                                                                       2
##                                             preserve communities of interest
## detect gerrymandering                                                      3
## public participation                                                       5
## floor votes align with district preferences                                3
## preserve communities of interest                                           0
## proportionality                                                            3
##                                             proportionality
## detect gerrymandering                                     6
## public participation                                      8
## floor votes align with district preferences               2
## preserve communities of interest                          3
## proportionality                                           0

edge_density is the proportion of edges in the network over all possible edges that could exist. Find the edge_density of the network.

edge_density(g)
## [1] 0.0227451
# 22*21 possible edges / 2 because it's undirected = 231 possible edges
# but only 60 exist
60/((22*21)/2)
## [1] 0.2597403

reciprocity measures the propensity of each edge to be a mutual edge; that is, the probability that if i is connected to j, j is also connected to i. Find the reciprocity of the network – you should find that it is 1. Explain why you think reciprocity=1 in this case.

reciprocity(g)
## [1] 0

transitivity, also known as clustering coefficient, measures that probability that adjacent nodes of a network are connected. In other words, if i is connected to j, and j is connected to k, what is the probability that i is also connected to k? Find the transitivity of the network.

transitivity(g)
## [1] 0.09933775

5 Network communities

Networks often have different clusters or communities of nodes that are more densely connected to each other than to the rest of the network. Let’s cover some of the different existing methods to identify these communities.

The most straightforward way to partition a network is into connected components. Each component is a group of nodes that are connected to each other, but not to the rest of the nodes. For example, this network has two components.

# components(g)
par(mar=c(0,0,0,0)); plot(g)

Most networks have a single giant connected component that includes most nodes. Most studies of networks actually focus on the giant component (e.g. the shortest path between nodes in a network with two or more component is Inf!).

giant <- decompose(g)[[1]]

Components can be weakly connected (in undirected networks) or __strongly connected (in directed networks, where there is an edge that ends in every single node of that component).

Even within a giant component, there can be different subsets of the network that are more connected to each other than to the rest of the network. The goal of community detection algorithms is to identify these subsets.

There are a few different algorithms, each following a different logic.

The walktrap algorithm finds communities through a series of short random walks. The idea is that these random walks tend to stay within the same community. The length of these random walks is 4 edges by default, but you may want to experiment with different values. The goal of this algorithm is to identify the partition that maximizes a modularity score.

cluster_walktrap(giant)
## IGRAPH clustering walktrap, groups: 6, mod: 0.53
## + groups:
##   $`1`
##   [1] "preserve communities of interest"        
##   [2] "voter sense of place"                    
##   [3] "rolloff"                                 
##   [4] "voter recall"                            
##   [5] "split ticket voting"                     
##   [6] "stability in voters' fellow constituents"
##   [7] "voter information about their district"  
##   
##   $`2`
##   + ... omitted several groups/vertices
cluster_walktrap(giant, steps=10)
## IGRAPH clustering walktrap, groups: 6, mod: 0.53
## + groups:
##   $`1`
##   [1] "detect gerrymandering"       "public participation"       
##   [3] "constitutional test"         "computers"                  
##   [5] "mean-median vote comparison"
##   
##   $`2`
##   [1] "preserve communities of interest"        
##   [2] "voter sense of place"                    
##   [3] "rolloff"                                 
##   [4] "voter recall"                            
##   + ... omitted several groups/vertices

Other methods are:

  • The fast and greedy method tries to directly optimize this modularity score.
  • The infomap method attempts to map the flow of information in a network, and the different clusters in which information may get remain for longer periods. Similar to walktrap, but not necessarily maximizing modularity, but rather the so-called “map equation”.
  • The edge-betweenness method iteratively removes edges with high betweenness, with the idea that they are likely to connect different parts of the network. Here betweenness (gatekeeping potential) applies to edges, but the intuition is the same.
  • The label propagation method labels each node with unique labels, and then updates these labels by choosing the label assigned to the majority of their neighbors, and repeat this iteratively until each node has the most common labels among its neighbors.
cluster_edge_betweenness(giant)
## IGRAPH clustering edge betweenness, groups: 6, mod: 0.45
## + groups:
##   $`1`
##    [1] "detect gerrymandering"                   
##    [2] "public participation"                    
##    [3] "preserve communities of interest"        
##    [4] "constitutional test"                     
##    [5] "voter sense of place"                    
##    [6] "rolloff"                                 
##    [7] "voter recall"                            
##    [8] "split ticket voting"                     
##    [9] "stability in voters' fellow constituents"
##   + ... omitted several groups/vertices
cluster_infomap(giant)
## IGRAPH clustering infomap, groups: 1, mod: 0
## + groups:
##   $`1`
##    [1] "detect gerrymandering"                      
##    [2] "public participation"                       
##    [3] "floor votes align with district preferences"
##    [4] "preserve communities of interest"           
##    [5] "proportionality"                            
##    [6] "number of competitive districts"            
##    [7] "efficiency gap"                             
##    [8] "constitutional test"                        
##    [9] "unconstitutional government interest"       
##   + ... omitted several groups/vertices
cluster_label_prop(giant)
## IGRAPH clustering label propagation, groups: 11, mod: 0.32
## + groups:
##   $`1`
##   [1] "detect gerrymandering" "public participation"  "computers"            
##   
##   $`2`
##   [1] "floor votes align with district preferences"
##   [2] "legislator information about district"      
##   
##   $`3`
##    [1] "preserve communities of interest"        
##    [2] "proportionality"                         
##   + ... omitted several groups/vertices

Infomap tends to work better in most social science examples (websites, social media, classrooms, etc), but fastgreedy is faster.

igraph also makes it very easy to plot the resulting communities:

# undirected graphs only
comm <- cluster_infomap(giant)
modularity(comm) # modularity score
par(mar=c(0,0,0,0)); plot(comm, giant)

Alternatively, we can also add the membership to different communities as a color parameter in the igraph object.

# for undirected graphs
V(giant)$color <- membership(comm)
par(mar=c(0,0,0,0)); plot(giant)

The final way in which we can think about network communities is in terms of hierarchy or structure. We’ll discuss one of these methods.

K-core decomposition allows us to identify the core and the periphery of the network. A k-core is a maximal subnet of a network such that all nodes have at least degree K.

coreness(g)
##                       detect gerrymandering 
##                                           1 
##                        public participation 
##                                           1 
## floor votes align with district preferences 
##                                           1 
##            preserve communities of interest 
##                                           2 
##                             proportionality 
##                                           1 
##             number of competitive districts 
##                                           3 
##                              efficiency gap 
##                                           3 
##                         constitutional test 
##                                           1 
##        unconstitutional government interest 
##                                           1 
##                                 instability 
##                                           1 
##                          elite polarization 
##                                           3 
##          number of minority representatives 
##                                           1 
##                          partisan advantage 
##                                           3 
##                               voter turnout 
##                                           2 
##                     partisan gerrymandering 
##                                           3 
##                    partisan donor advantage 
##                                           1 
##                           legislator voting 
##                                           1 
##                        legislative outcomes 
##                                           1 
##                        incumbent vote share 
##                                           1 
##                               personal vote 
##                                           1 
##                               pork spending 
##                                           1 
##                        voter sense of place 
##                                           1 
##                                     rolloff 
##                                           2 
##                                voter recall 
##                                           1 
##                         split ticket voting 
##                                           1 
##                campaign resource allocation 
##                                           1 
##    stability in voters' fellow constituents 
##                                           1 
##      voter information about their district 
##                                           2 
##    floor votes align with state preferences 
##                                           1 
##           House-Senate Delegation alignment 
##                                           1 
##                     minority representation 
##                                           1 
##                                 compactness 
##                                           2 
##                            equal population 
##                                           2 
##          representation of majority opinion 
##                                           1 
##                elite ideological moderation 
##                                           1 
##                             competitiveness 
##                                           2 
##       legislative majority-seeking behavior 
##                                           1 
##                        partisan dislocation 
##                                           2 
##                                   computers 
##                                           1 
##       legislator information about district 
##                                           1 
##                 mean-median vote comparison 
##                                           1 
##                 majority minority districts 
##                                           2 
##                    redistricting commission 
##                                           2 
##           change in constituency boundaries 
##                                           1 
##                                     sorting 
##                                           1 
##                                  contiguity 
##                                           1 
##               electorate composition change 
##                                           1 
##             incumbent's constituents change 
##                                           1 
##                       geographic clustering 
##                                           1 
##                     redistricting by courts 
##                                           1 
##                      upcoming redistricting 
##                                           1
which(coreness(g)==6) # what is the core of the network?
## named integer(0)
which(coreness(g)==1) # what is the periphery of the network?
##                       detect gerrymandering 
##                                           1 
##                        public participation 
##                                           2 
## floor votes align with district preferences 
##                                           3 
##                             proportionality 
##                                           5 
##                         constitutional test 
##                                           8 
##        unconstitutional government interest 
##                                           9 
##                                 instability 
##                                          10 
##          number of minority representatives 
##                                          12 
##                    partisan donor advantage 
##                                          16 
##                           legislator voting 
##                                          17 
##                        legislative outcomes 
##                                          18 
##                        incumbent vote share 
##                                          19 
##                               personal vote 
##                                          20 
##                               pork spending 
##                                          21 
##                        voter sense of place 
##                                          22 
##                                voter recall 
##                                          24 
##                         split ticket voting 
##                                          25 
##                campaign resource allocation 
##                                          26 
##    stability in voters' fellow constituents 
##                                          27 
##    floor votes align with state preferences 
##                                          29 
##           House-Senate Delegation alignment 
##                                          30 
##                     minority representation 
##                                          31 
##          representation of majority opinion 
##                                          34 
##                elite ideological moderation 
##                                          35 
##       legislative majority-seeking behavior 
##                                          37 
##                                   computers 
##                                          39 
##       legislator information about district 
##                                          40 
##                 mean-median vote comparison 
##                                          41 
##           change in constituency boundaries 
##                                          44 
##                                     sorting 
##                                          45 
##                                  contiguity 
##                                          46 
##               electorate composition change 
##                                          47 
##             incumbent's constituents change 
##                                          48 
##                       geographic clustering 
##                                          49 
##                     redistricting by courts 
##                                          50 
##                      upcoming redistricting 
##                                          51
# Visualizing network structure
V(g)$coreness <- coreness(g)
par(mfrow=c(2, 3), mar=c(0.1,0.1,1,0.1))
set.seed(777); fr <- layout_with_fr(g)
for (k in 1:6){
  V(g)$color <- ifelse(V(g)$coreness>=k, "orange", "grey")
  plot(g, main=paste0(k, '-core shell'), layout=fr)
}

wc <- cluster_walktrap(g)
modularity(wc)
## [1] 0.5766944
membership(wc)
##                       detect gerrymandering 
##                                           3 
##                        public participation 
##                                           3 
## floor votes align with district preferences 
##                                           2 
##            preserve communities of interest 
##                                           1 
##                             proportionality 
##                                           5 
##             number of competitive districts 
##                                           2 
##                              efficiency gap 
##                                           2 
##                         constitutional test 
##                                           3 
##        unconstitutional government interest 
##                                           2 
##                                 instability 
##                                           2 
##                          elite polarization 
##                                           2 
##          number of minority representatives 
##                                           2 
##                          partisan advantage 
##                                           2 
##                               voter turnout 
##                                           4 
##                     partisan gerrymandering 
##                                           2 
##                    partisan donor advantage 
##                                           2 
##                           legislator voting 
##                                           6 
##                        legislative outcomes 
##                                           6 
##                        incumbent vote share 
##                                           7 
##                               personal vote 
##                                           7 
##                               pork spending 
##                                           5 
##                        voter sense of place 
##                                           1 
##                                     rolloff 
##                                           1 
##                                voter recall 
##                                           1 
##                         split ticket voting 
##                                           1 
##                campaign resource allocation 
##                                           7 
##    stability in voters' fellow constituents 
##                                           1 
##      voter information about their district 
##                                           1 
##    floor votes align with state preferences 
##                                           2 
##           House-Senate Delegation alignment 
##                                           5 
##                     minority representation 
##                                           8 
##                                 compactness 
##                                           8 
##                            equal population 
##                                          10 
##          representation of majority opinion 
##                                           4 
##                elite ideological moderation 
##                                           4 
##                             competitiveness 
##                                           4 
##       legislative majority-seeking behavior 
##                                           9 
##                        partisan dislocation 
##                                          11 
##                                   computers 
##                                           3 
##       legislator information about district 
##                                           2 
##                 mean-median vote comparison 
##                                           3 
##                 majority minority districts 
##                                           2 
##                    redistricting commission 
##                                           4 
##           change in constituency boundaries 
##                                           6 
##                                     sorting 
##                                           2 
##                                  contiguity 
##                                           2 
##               electorate composition change 
##                                           7 
##             incumbent's constituents change 
##                                           2 
##                       geographic clustering 
##                                           2 
##                     redistricting by courts 
##                                           4 
##                      upcoming redistricting 
##                                           9
V(g)$shortname<-V(g)$name #shortened easier to read ver name
V(g)$shortname[V(g)$shortname=="concentration of likely donors in map-drawing party's districts"]<- "donor concentration"
V(g)$shortname[V(g)$shortname=="individual legislator voting"]<- "legislator voting"
V(g)$shortname[V(g)$shortname=="effect of personal vote"]<- "personal vote"
V(g)$shortname[V(g)$shortname=="detect gerrymandering"]<- "detect gerrymander"
V(g)$shortname[V(g)$shortname=="proportional minority representation"]<- "prop. minority rep"
V(g)$shortname[V(g)$shortname=="Number of competitive districts"]<- "no. competitive district"
V(g)$shortname[V(g)$shortname=="legislator information about district"]<- "legis. info on district"
V(g)$shortname[V(g)$shortname=="floor votes align with district preferences"]<- "legis. votes with district pref."
V(g)$shortname[V(g)$shortname=="stability in voters' fellow constituents"]<- "constituent stability"
V(g)$shortname[V(g)$shortname=="voter information about their district"]<- "voter info on district"
V(g)$shortname[V(g)$shortname=="legislator information seeking"]<- "legis. info-seek"
V(g)$shortname[V(g)$shortname=="Alignment of floor vote breakdown with statewide majority of voters"]<- "Floor vote align state voters"
V(g)$shortname[V(g)$shortname=="number of competitive districts" ]<- "no. competitive district" 
V(g)$shortname[V(g)$shortname=="House-Senate Delegation alignment" ]<- "Congress-SH align" 
V(g)$shortname[V(g)$shortname=="unconstitutional government interest"]<- "unconstit gov interest"
V(g)$shortname[V(g)$shortname=="number of minority representatives"]<- "no. minority reps"
V(g)$shortname[V(g)$shortname=="representation of majority opinion"]<- "represent majority opinion"
V(g)$shortname[V(g)$shortname=="elite ideological moderation"]<- "elite ideol moderation"
V(g)$shortname[V(g)$shortname=="partisan gerrymandering"]<- "partisan gerrymander"
V(g)$shortname[V(g)$shortname=="legislative majority-seeking behavior"]<- "legis majority-seeking behavior"
V(g)$shortname[V(g)$shortname=="change in constituency boundaries"]<- "change constituent boundary"
V(g)$shortname[V(g)$shortname=="demographic and ideological sorting"]<- "demog/ideol sorting"
V(g)$shortname[V(g)$shortname=="dispersed minority population"]<- "dispersed minority pop"
V(g)$shortname[V(g)$shortname=="majority minority districts"]<- "majority minority district"

set.seed(123)
pdf(file=here::here("figs","redistrict_communities.pdf"),width=13,height=13)
plot(g)
plot(wc, g, vertex.label=V(g)$shortname,vertex.label.dist=1,vertex.color="gray20")
dev.off()
## quartz_off_screen 
##                 2
plot(g)